import 'package:flutter/material.dart';
import 'package:yysk_app/utils/helper.dart';
import 'package:lottie/lottie.dart';

class LoadingContainer extends StatelessWidget {
  final Widget child;
  final bool isLoading;
  final bool cover;

  const LoadingContainer({
    super.key,
    required this.child,
    required this.isLoading,
    this.cover = false,
  });

  get _loadingView => Center(
        child:
            Lottie.asset('static/json/kongfu.json', width: 50.px, height: 50.px),
      );
  get coverView => Stack(
        //堆叠效果
        children: [child, isLoading ? _loadingView : Container()],
      );

  get normalView => isLoading ? _loadingView : child;

  @override
  Widget build(BuildContext context) {
    return cover ? coverView : normalView;
  }
}
